@isTest
private class testTaskEditDeleteTrigger {

    static testMethod void myUnitTest() {
    User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];  
    System.runAs ( thisUser ) {  
         All_Security_Extensions__c permissionsCS = new All_Security_Extensions__c() ; //[ Select Can_edit_closed_tasks__c, Can_Delete_Closed_Tasks__c From All_Security_Extensions__c  Limit 1];
       
           permissionsCS.Ignore_Some_Workflow_Rules__c = true;
           permissionsCS.Ignore_Some_Validation_Rules__c = true;
           permissionsCS.Can_Edit_Closed_Tasks__c = true;
           permissionsCS.Can_Delete_Closed_Tasks__c = true;
           permissionsCS.Can_Create_Invalid_Leads__c = true;
           permissionsCS.Description__c = 'null data';
           
           insert permissionsCS;
           
            if(permissionsCS != null) {
              
              permissionsCS.Can_edit_closed_tasks__c = false;
              permissionsCS.Can_Delete_Closed_Tasks__c = false ;
              Database.update(permissionsCS);
              
              
            }
            else
            {
              permissionsCS = new All_Security_Extensions__c(SetupOwnerId = UserInfo.getOrganizationId());
              permissionsCS.Can_edit_closed_tasks__c = false;
              permissionsCS.Can_Delete_Closed_Tasks__c = false ;
              Database.upsert(permissionsCS);
            }
    
    Task t = new Task();
    t.subject = 'test';
    t.status = 'Completed';
    t.Type = 'Other';
    insert t;
    
    t.Priority = 'Normal';
    try {
    update t;
    }
    catch(Exception e){}
 
    try {
    delete t;
    }
    catch(Exception e){}   
   
    
    permissionsCS.Can_edit_closed_tasks__c = true;
    permissionsCS.Can_Delete_Closed_Tasks__c = true ;
    
    update permissionsCS; 
    Task t2 = new Task();
    t2.subject = 'test';
    t2.status = 'Completed';
    t2.Type = 'Other';
    insert t2;
    
    t2.Priority = 'Normal';
   
    try {
    update t2;
    }
    catch(Exception e){}
 
    try {
    delete t2;
    }
    catch(Exception e){}
    


    }
    }
}